package com.smartum.mpr.model;

import java.io.Serializable;

public class ItemPurchase implements Serializable {

	private static final long serialVersionUID = 1L;

	private User user;
	private ItemCategory category;
	private long receiptId;
	private long expireTimestamp;
	private String transactionReceipt;

	public long getExpireTimestamp() {
		return expireTimestamp;
	}

	public void setExpireTimestamp(long expireTimestamp) {
		this.expireTimestamp = expireTimestamp;
	}

	public User getUser() {
		return user;
	}

	public void setUser(User user) {
		this.user = user;
	}

	public ItemCategory getCategory() {
		return category;
	}

	public void setCategory(ItemCategory category) {
		this.category = category;
	}

	public long getReceiptId() {
		return receiptId;
	}

	public void setReceiptId(long receiptId) {
		this.receiptId = receiptId;
	}

	public String getTransactionReceipt() {
		return transactionReceipt;
	}

	public void setTransactionReceipt(String transactionReceipt) {
		this.transactionReceipt = transactionReceipt;
	}

	@Override
	public boolean equals(Object obj) {
		return user.getId().equals(((ItemPurchase) obj).getUser().getId())
		        && category.getId().equals(((ItemPurchase) obj).getCategory().getId());
	}

	@Override
	public int hashCode() {
		return user.getId().hashCode() + category.getId().hashCode();
	}

}
